home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-03 / menuman.zip / VIEWDOC.BAS < prev   
BASIC Source File  |  1992-04-06  |  3KB  |  84 lines

  1. ' VIEWDOC.BAS, a modification of Matt Hart's Public Domain program,
  2. ' VIEWFILE.BAS
  3. ' View any size text file without any temporary files.
  4. ' Keeps the SEEK position of each line in a long integer array -
  5. ' which does limit this to 16,384 lines of text (and makes this
  6. ' program easy, small, and fast.)
  7. '
  8.     '$DYNAMIC
  9.     DEFINT A-Z
  10. '
  11.     CONST false = 0
  12.     CONST true = NOT false
  13.     CLS
  14.     File$ = "MENUMAN.DOC"
  15.     OPEN "I", 1, File$
  16.     REDIM Seeks&(1 TO 16384)        ' Max number of lines if 16384
  17.     CurSeek& = 1
  18.     NumLines = 0
  19.     DO UNTIL EOF(1)
  20.         LINE INPUT #1, Text$
  21.         NumLines = NumLines + 1
  22.         Seeks&(NumLines) = CurSeek&          ' Save starting position
  23.         CurSeek& = CurSeek& + LEN(Text$) + 2 ' Next position - 2 is
  24.     LOOP                                     ' for C/R & LF
  25. '
  26.     CurCol = 1                               ' Current Column
  27.     SeekEl = 1                               ' Current line
  28.     escape = false
  29.  
  30.     DO
  31.        GOSUB LoadAndDisplay
  32.        GOSUB KeyProcess
  33.     LOOP UNTIL escape
  34.  
  35.     CLOSE 1
  36.     END
  37.  
  38. LoadAndDisplay:
  39.     SEEK #1, Seeks&(SeekEl)
  40.     FOR i = 1 TO 24
  41.         IF NOT EOF(1) THEN LINE INPUT #1, Text$ ELSE Text$ = ""
  42.         Strg$ = SPACE$(80)
  43.         IF LEN(Text$) < CurCol THEN Text$ = Text$ + SPACE$(CurCol - LEN(Text$))
  44.          LSET Strg$ = MID$(Text$, CurCol)
  45.         LOCATE i, 1, 0: PRINT Strg$;
  46.         LOCATE 1, 1: COLOR 0, 15: PRINT " Key controls: down left, right, page up, page down, end, home; ESC TO QUIT   ": COLOR 15, 0
  47.  
  48.     NEXT i
  49. RETURN
  50.  
  51. KeyProcess:
  52.     A$ = INKEY$: IF A$ = "" THEN GOTO KeyProcess
  53.     SELECT CASE A$
  54.         CASE CHR$(27): escape = true        ' ESC
  55.         CASE CHR$(0) + CHR$(72)             ' Up Arrow
  56.             SeekEl = SeekEl - 1
  57.             IF SeekEl < 1 THEN SeekEl = 1: GOTO KeyProcess
  58.         CASE CHR$(0) + CHR$(80)             ' Dn Arrow
  59.             SeekEl = SeekEl + 1
  60.             IF SeekEl + 23 > NumLines THEN SeekEl = SeekEl - 1: GOTO KeyProcess
  61.          CASE CHR$(0) + CHR$(77)             ' Right Arrow
  62.             CurCol = CurCol + 1
  63.         CASE CHR$(0) + CHR$(75)             ' Left Arrow
  64.             CurCol = CurCol - 1
  65.             IF CurCol < 1 THEN CurCol = 1: GOTO KeyProcess
  66.         CASE CHR$(0) + CHR$(73)             ' Page Up
  67.             SeekEl = SeekEl - 24
  68.             IF SeekEl < 1 THEN SeekEl = 1
  69.         CASE CHR$(0) + CHR$(81)             ' Page Dn
  70.             SeekEl = SeekEl + 24
  71.             IF SeekEl > NumLines THEN
  72.                 SeekEl = NumLines - 23: GOTO KeyProcess
  73.             END IF
  74.         CASE CHR$(0) + CHR$(71)                       ' Home
  75.             SeekEl = 1
  76.         CASE CHR$(0) + CHR$(79)                       ' End
  77.             SeekEl = NumLines - 23
  78.             IF SeekEl < 1 THEN SeekEl = 1: GOTO KeyProcess
  79.         CASE ELSE
  80.             GOTO KeyProcess
  81.     END SELECT
  82. RETURN
  83.  
  84.